﻿using System;
using System.Web.Mvc;

using Ninject.Core;
using Ninject.Core.Parameters;

using BlueSky.Web.IoC;
using BlueSky.Web.Extentions;

namespace BlueSky.Web.IoC.Ninject
{
    internal class NinjectControllerResolver : IDependencyResolver
    {
        public object Resolve(Type controllerType)
        {
            return (IController)NinjectKernel.Kernel.Get(controllerType, With.Parameters.ByController(controllerType));
        }

        public T Resolve<T>()
        {
            return (T)this.Resolve(typeof(T));
        }

        public void Release(object instance)
        {
            NinjectKernel.Kernel.Release(instance);
        }


    }
}
